SRC=$(shell ls *.c)
OBJ=$(SRC:.c=.o)
LIB=libmyc.so

LINK_OBJ=$(filter-out main.o,$(OBJ))

#依赖关系中已经不包含main.c了
$(LIB):$(LINK_OBJ)
	gcc -shared -o $@ $^
%.o:%.c
	gcc -c -fPIC $<

.PHONY:output
output:
	mkdir -p ./lib/include
	mkdir -p ./lib/mylib
	mv *.h ./lib/include
	mv *.so ./lib/mylib
	tar -czf lib.tgz lib

.PHONY:clean
clean:
	rm -rf $(OBJ) $(LIB) log.txt lib* mycode
